package com.ruoyi.law_model.knowledge.service.impl;

import java.util.Date;
import java.util.List;

import com.ruoyi.law_model.knowledge.domain.Knowledge;
import com.ruoyi.law_model.knowledge.mapper.KnowledgeMapper;
import com.ruoyi.law_model.knowledge.service.IKnowledgeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 存储知识库Service业务层处理
 *
 * @author ruoyi
 * @date 2025-01-09
 */
@Service
public class KnowledgeServiceImpl implements IKnowledgeService
{
    @Autowired
    private KnowledgeMapper knowledgeMapper;

    /**
     * 查询存储知识库
     *
     * @param klId 存储知识库主键
     * @return 存储知识库
     */
    @Override
    public Knowledge selectKnowledgeByKlId(Long klId)
    {
        return knowledgeMapper.selectKnowledgeByKlId(klId);
    }

    /**
     * 查询存储知识库列表
     *
     * @param knowledge 存储知识库
     * @return 存储知识库
     */
    @Override
    public List<Knowledge> selectKnowledgeList(Knowledge knowledge)
    {
        return knowledgeMapper.selectKnowledgeList(knowledge);
    }

    /**
     * 新增存储知识库
     *
     * @param knowledge 存储知识库
     * @return 结果
     */
    @Override
    public int insertKnowledge(Knowledge knowledge)
    {
        knowledge.setCreatedAt(new Date());
        knowledge.setUpdatedAt(new Date());
        return knowledgeMapper.insertKnowledge(knowledge);
    }

    /**
     * 修改存储知识库
     *
     * @param knowledge 存储知识库
     * @return 结果
     */
    @Override
    public int updateKnowledge(Knowledge knowledge)
    {
        knowledge.setUpdatedAt(new Date());
        return knowledgeMapper.updateKnowledge(knowledge);
    }

    /**
     * 批量删除存储知识库
     *
     * @param klIds 需要删除的存储知识库主键
     * @return 结果
     */
    @Override
    public int deleteKnowledgeByKlIds(Long[] klIds)
    {
        return knowledgeMapper.deleteKnowledgeByKlIds(klIds);
    }

    /**
     * 删除存储知识库信息
     *
     * @param klId 存储知识库主键
     * @return 结果
     */
    @Override
    public int deleteKnowledgeByKlId(Long klId)
    {
        return knowledgeMapper.deleteKnowledgeByKlId(klId);
    }
}
